﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> 
  <head> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/> 
    <title>宠物在哪里？</title> 
<script src="http://ditu.google.cn/maps?file=api&amp;v=2&amp;key=ABQIAAAAPFQCmHOz6t9Vl6uJiifSLRSoZUzq6CBrikiwygzQ-gsGnM0hAhRadtoeMS81bbID7QwcplR2FMbd8w"
type="text/javascript">
</script>
<?php
require('mysql.php');
$id=isset($_GET['point_id'])?$_GET['point_id']:NULL;//id
if($id!=NULL){
$map_sql="select * from points where id='".$id."' order by order_id desc limit 0,1";
$map_result=mysql_query($map_sql);
$map_array=mysql_fetch_array($map_result);
$lat=$map_array['latitude'];
$lng=$map_array['longitude'];
}
else{$lat=0;$lng=0;}
?>
 
<script type="text/javascript"> 

 function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
	    var point = new GLatLng(<?php echo $lat;?>, <?php echo $lng;?>);
        map.setCenter(point, 8);
		map.addOverlay(new GMarker(point));
      }
    }
 
</script> 

  </head> 
  <body onload="initialize()" onunload="GUnload()">
  <form action="index.php" method="get" name="point_form" id="point_form">
  <select id="point_id" name="point_id" onchange="point_form.submit()">
  <option>请选择ID</option>
  <?php 
  $get_points_sql="select *, count(distinct id) from points group by id";
  $points_result=mysql_query($get_points_sql);
  
  
  while($points_array=mysql_fetch_array($points_result))
  {?><option value="<?php echo $points_array['id'];?>"><?php echo $points_array['id'];?></option><?php }?>

  </select>
  </form> 

  <a href="http://127.0.0.1/petslocation/gps.php?id=3&amp;lat=39&amp;lng=116.04">添加位置
  </a>
  <div id="map_canvas" style="width: 780px; height: 500px"></div> 
  </body> 
</html> 